import 'package:flutter/material.dart';
import '../services/ScreenAdapter.dart';

// 自定义按钮组件
class JdButton extends StatelessWidget {
  final Color color;
  final String text;
  final void Function()? cb; // 事件
  final double height;

  const JdButton(
      {super.key,
      this.color = Colors.blue,
      this.text = "按钮",
      this.height = 68,
      required this.cb});

  @override
  Widget build(BuildContext context) {
    ScreenAdapter.init(context);

    return InkWell(
      onTap: cb,
      child: Container(
        margin: const EdgeInsets.all(5),
        padding: const EdgeInsets.all(5),
        height: ScreenAdapter.height(height),
        width: double.infinity,
        decoration: BoxDecoration(
            color: color, borderRadius: BorderRadius.circular(10)),
        child: Center(
          child: Text(
            text,
            style: const TextStyle(
              color: Colors.white,
              fontWeight: FontWeight.bold,
              fontSize: 20,
            ),
          ),
        ),
      ),
    );
  }
}
